package com.hxzy.module.merchant.api.fallback;

import com.hxzy.framework.common.resp.R;
import com.hxzy.framework.common.resp.ResultCode;
import com.hxzy.module.merchant.api.merchant.MerchantFeignApi;
import com.hxzy.module.merchant.api.merchant.resp.MerchantResp;
import feign.hystrix.FallbackFactory;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

/**
 * @Author wy
 * @Description TODO
 * @Date 2024/1/27 9:36
 * @Version 1.0
 */
@Log4j2
@Component
public class MerchantFeignApiFallbackFactory implements FallbackFactory<MerchantFeignApi> {
    @Override
    public MerchantFeignApi create(Throwable throwable) {
        log.error(throwable);
        return new MerchantFeignApiFallbackFactoryImpl();
    }

    class MerchantFeignApiFallbackFactoryImpl implements  MerchantFeignApi{


        @Override
        public R<MerchantResp> getMerchantDetail() {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R<MerchantResp> findMerchantById(Long id) {
            return R.failed(ResultCode.DEMOTION);
        }
    }
}
